open read and writing text files in c